//package com.yanzq;
//
//import cn.hutool.core.io.IoUtil;
//import com.yanzq.pojo.User;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//
//import java.io.InputStream;
//import java.nio.charset.StandardCharsets;
//import java.time.LocalDateTime;
//import java.time.format.DateTimeFormatter;
//import java.util.ArrayList;
//import java.util.List;
//import java.util.stream.Collectors;
//
//@RestController//ResponseBody->作用：将controller返回值直接作为响应体的数据响应，返回值是对象/集合，会先转为json字符串
//public class UserInfoController {
//    @RequestMapping("/user")
//    public List<User> getUserInfo(){
//        List<String> list = new ArrayList<>();
//        InputStream in = this.getClass().getResourceAsStream("/user.txt");
//        List<String> lines = IoUtil.readLines(in, StandardCharsets.UTF_8, new ArrayList<>());
//        List<User> result = lines.stream().map((line) ->{
//            String[] arr = line.split(",");
//            int id = Integer.parseInt(arr[0]);
//            String name = arr[1];
//            int age = Integer.parseInt(arr[2]);
//            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
//            LocalDateTime lastUpdate = LocalDateTime.parse(arr[3], formatter);
//            return new User(id, name, age, lastUpdate);
//        }).collect(Collectors.toList());
//        return result;
//    }
//}
